﻿using FinalTestMachine.Funs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkItemHelper2;

namespace FinalTestMachine.View
{
    /// <summary>
    /// 工单/换型 管理类
    /// </summary>
    public static class WorkItemManagerHelper
    {
        static WorkItemManagerHelper()
        {
            WorkItemHelper2.BackUp.BackUpZipHelper.SoureDirList.Add("Bas");
            WorkItemHelper2.BackUp.BackUpZipHelper.SoureDirList.Add("AviewConfigs");
            WorkItemHelper2.BackUp.BackUpZipHelper.SoureDirList.Add("CommunicationCfg");
            WorkItemHelper2.BackUp.BackUpZipHelper.SoureDirList.Add("SysCfg");

            workIterm = new ParamWorkIterm(Motion.ParamPath_Motion.ModelRoot,
                () => Motion.ParamPath_Motion.SelectedDirPath,
                 Motion.ParamPath_Motion.ResetLoadFold);

            workIterm.LoadedWorkItemEventHandler += ISaveReaddll.SaveReadManagerHelper.Fun_ReadAll;
            workIterm.LoadedWorkItemEventHandler += SpotInspectionFacility.ProductInfoManger.Cur.ChangeMode;

            for (int i = 0; i < GlobalParams.WorkstationSum; i++) {
                int index = i;
                workIterm.LoadedWorkItemEventHandler += () => Connect.SiteConnectManager.Cur.GetCommunicationHelper(index+1).SendToChangeType();
            }
        }

        public static readonly WorkItemHelper2.ParamWorkIterm workIterm;

        /// <summary>
        /// 当前加载的参数文件的名字
        /// </summary>
        public static string LoadedName
        {
            get { return Motion.ParamPath_Motion.SelectedDirName; }
        }
    }
}